.\"***************************************************************************
.\" Copyright 2018-2021,2022 Thomas E. Dickey                                *
.\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
.\"                                                                          *
.\" Permission is hereby granted, free of charge, to any person obtaining a  *
.\" copy of this software and associated documentation files (the            *
.\" "Software"), to deal in the Software without restriction, including      *
.\" without limitation the rights to use, copy, modify, merge, publish,      *
.\" distribute, distribute with modifications, sublicense, and/or sell       *
.\" copies of the Software, and to permit persons to whom the Software is    *
.\" furnished to do so, subject to the following conditions:                 *
.\"                                                                          *
.\" The above copyright notice and this permission notice shall be included  *
.\" in all copies or substantial portions of the Software.                   *
.\"                                                                          *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
.\"                                                                          *
.\" Except as contained in this notice, the name(s) of the above copyright   *
.\" holders shall not be used in advertising or otherwise to promote the     *
.\" sale, use or other dealings in this Software without prior written       *
.\" authorization.                                                           *
.\"***************************************************************************
.\"
.\" $Id: curs_scr_dump.3x,v 1.20 2022/02/12 20:05:11 tom Exp $
.TH scr_dump 3NCURSES ""
.ie \n(.g .ds `` \(lq
.el       .ds `` ``
.ie \n(.g .ds '' \(rq
.el       .ds '' ''
.de bP
.ie n  .IP \(bu 4
.el    .IP \(bu 2
..
.na
.hy 0
.SH NAME
\fBscr_dump\fP,
\fBscr_restore\fP,
\fBscr_init\fP,
\fBscr_set\fP \- read (write) a \fBcurses\fP screen from (to) a file
.ad
.hy
.SH SYNOPSIS
\fB#include <curses.h>\fP
.sp
\fBint scr_dump(const char *\fIfilename\fB);\fR
.br
\fBint scr_restore(const char *\fIfilename\fB);\fR
.br
\fBint scr_init(const char *\fIfilename\fB);\fR
.br
\fBint scr_set(const char *\fIfilename\fB);\fR
.br
.SH DESCRIPTION
.SS scr_dump
.PP
The \fBscr_dump\fP routine dumps the current contents
of the \fIvirtual screen\fP
to the file \fIfilename\fP.
.SS scr_restore
.PP
The \fBscr_restore\fP routine sets the \fIvirtual screen\fP to the contents
of \fIfilename\fP, which must have been written using \fBscr_dump\fP.
The next call to \fBdoupdate\fP restores
the \fIphysical screen\fP to the way it looked in the dump file.
.SS scr_init
.PP
The \fBscr_init\fP routine reads in the contents of \fIfilename\fP and uses
them to initialize the \fBcurses\fP data structures about what the terminal
currently has on its screen.
If the data is determined to be valid,
\fBcurses\fP bases its next update of the screen on this information rather
than clearing the screen and starting from scratch.
\fBscr_init\fP is used
after \fBinitscr\fP(3X) or a \fBsystem\fP(3) call to share
the screen with another process which has done a \fBscr_dump\fP after its
\fBendwin\fP(3X) call.
The data is declared invalid
.bP
if the terminfo capabilities \fBrmcup\fP and \fBnrrmc\fP exist, also
.bP
if the terminal has been written to since the preceding \fBscr_dump\fP call.
.SS scr_set
.PP
The \fBscr_set\fP routine is a combination of \fBscr_restore\fP and
\fBscr_init\fP.  It tells the program that the information in \fIfilename\fP is
what is currently on the screen, and also what the program wants on the screen.
This can be thought of as a screen inheritance function.
.PP
To read (write) a window from (to) a file, use the \fBgetwin\fP and
\fBputwin\fP routines [see \fButil\fP(3NCURSES)].
.SH RETURN VALUE
All routines return the integer \fBERR\fP upon failure and \fBOK\fP
upon success.
.PP
X/Open defines no error conditions.
In this implementation,
each will return an error if the file cannot be opened.
.SH NOTES
Note that \fBscr_init\fP, \fBscr_set\fP, and \fBscr_restore\fP may be macros.
.SH PORTABILITY
The XSI Curses standard, Issue 4, describes these functions (adding the const
qualifiers).
.PP
The SVr4 docs merely say under \fBscr_init\fP that the dump data is also
considered invalid "if the time-stamp of the tty is old" but do not define
\*(``old\*(''.
.SH SEE ALSO
\fBncurses\fP(3NCURSES),
\fBinitscr\fP(3NCURSES),
\fBrefresh\fP(3NCURSES),
\fButil\fP(3NCURSES),
\fBscr_dump\fP(5),
\fBsystem\fP(3)
